




var _oConst =
{

sGridIconControlName:	"fileGridIcon",
sOlkIconControlName:	"fileOutlookShortcutIcon",
sLrgIconControlName:	"fileLargeEntityIcon",


sGifExtension:			"gif",
sIconExtension:			"ico",
iMaxFileNameLength:		185,


iResultCheckDelay:		100,
sTargetIframeName:		"ifrmUploadResults",
sReadyStateComplete:	"complete",
sResultNodeId:			"divResult",
sResultSuccess:			"success"
};







var _oErrors =
{
sGridIconFileNameTooLong:		LOCID_UPDICNS_GI_FNTOOLONG,
sInvalidGridIconFileExtension:	LOCID_UPDICNS_GI_INVALEXT,
sLrgIconFileNameTooLong:		LOCID_UPDICNS_LE_FNTOOLONG,
sInvalidLrgIconFileExtension:	LOCID_UPDICNS_LE_INVALEXT,
sOlkIconFileNameTooLong:		LOCID_UPDICNS_OI_FNTOOLONG,
sInvalidOlkIconFileExtension:	LOCID_UPDICNS_OI_INVALEXT
};










function cancel()
{
window.returnValue = null;
window.close();
}






function applychanges()
{
if (validateParameters())
{
submitIcons();
}
}




function submitIcons()
{

frmIconUpload.submit();


checkResult();
}

function checkResult()
{

var oDocument = document.frames[_oConst.sTargetIframeName].document;


if (oDocument.readyState != _oConst.sReadyStateComplete)
{

setTimeout(checkResult, _oConst.iResultCheckDelay);
}
else
{

var sResult = oDocument.all(_oConst.sResultNodeId).innerText;
if (sResult != _oConst.sResultSuccess)
{

showError(sResult);
}
else
{

window.close();
}
}
}










function validateParameters()
{
var bValid = true;
bValid = bValid && validateFileName(_oConst.sGridIconControlName, _oConst.sGifExtension, _oErrors.sGridIconFileNameTooLong, _oErrors.sInvalidGridIconFileExtension);
bValid = bValid && validateFileName(_oConst.sOlkIconControlName, _oConst.sIconExtension, _oErrors.sOlkIconFileNameTooLong, _oErrors.sInvalidOlkIconFileExtension);
bValid = bValid && validateFileName(_oConst.sLrgIconControlName, _oConst.sGifExtension, _oErrors.sLrgIconFileNameTooLong, _oErrors.sInvalidLrgIconFileExtension);

return bValid;
}






function validateFileName(sControlName, sExpectedExtension, sFileNameTooLong, sInvaidExtension)
{
var oControl = document.all(sControlName);
var sFileName = oControl.value;

if (sFileName != "")
{

if (sFileName.length > _oConst.iMaxFileNameLength)
{
alert(sFileNameTooLong);
oControl.focus();
return false;
}


sFileName = sFileName.slice(sFileName.lastIndexOf("\\") + 1);
var sExtension = sFileName.slice(sFileName.lastIndexOf(".") + 1).toLowerCase();

if (sExtension != sExpectedExtension)
{
alert(sInvaidExtension);
oControl.focus();
return false;
}
}

return true;
}
